
#ifndef __UM_PATH_H
#define __UM_PATH_H

#include "filesystem.hpp"

template <class T>
class BasicPath
{

	typedef T char_type;
	

#if defined(WIN32)
	struct Rep : public CStringT< T, StrTraitATL<T> >
	{
		void append(const char_type* s) {
			Append(s);
		}

		void append(char_type ch) {
			AppendChar(ch);
		}
	};
#else
  
#endif

#if defined(WIN32)
	static const char_type DELIM = '\\';
#elif defined(UNIX)
	static const char_type DELIM = '/';
#endif

	//typedef std::char_traits<T> char_traits;

public:

	BasicPath(const char_type* root = 0) {
		if (root != 0) {
			_rep()->append(root);
		}
	}

	~BasicPath() {
	}

	void append(const char_type* name) {
		_rep()->append(DELIM);
		_rep()->append(name);
	}

	bool isPathExists() const {
		return FileSystem::isPathExists(toString());
	}

	static bool isPathExists(const char_type* path) {
		return FileSystem::isPathExists(path);
	}

	bool createDirectory() {
		return FileSystem::createDirectory(toString());
	}

	const char_type* toString() const {
		return (*_rep());
	}

private:

	Rep* _rep() {
		return &m_rep;
	}

	const Rep* _rep() const {
		return &m_rep;
	}

	Rep m_rep;
};

typedef BasicPath<TCHAR> Path;

#endif // __UM_PATH_H
